<?php
namespace app\admin\controller;

use app\common\controller\Back;

class Logs extends Back
{
    private $pageSize = 20;
    
    protected function initialize()
    {
        parent::initialize();
    }
    
    public function index()
    {
        $args = [
            'where' => [],
            'order' => [
                'log_id' => 'desc',
            ],
        ];
        //名称
        if(in_array($this->query['name'],model('common/Log','loglic')->names)){
            array_push($args['where'],['log_name','eq',$this->query['name']]);
        }
        //类型
        if(in_array($this->query['type'],model('common/Log','loglic')->types)){
            array_push($args['where'],['log_type','eq',$this->query['type']]);
        }
        //查询数据
        $list = model('common/Log','loglic')->selectPage($args,$this->pageSize,$this->site['page'],false,$this->query);
        // 获取分页显示
        $pages = $list->render();
        // 模板变量赋值
        $this->assign('list', $list);
        $this->assign('pages', $pages);
        $this->assign($this->query);
        $this->assign($this->site);
        // 渲染模板输出
        return $this->fetch();
    }
}